<h2>Listando Tarefas</h2>

<ul>
    <li><a href="<?=$this->url(array('controller'=>'tarefas','action'=>'add'));?>">Criar nova Tarefa</a></li>
</ul>

<table>
    <tr>
        <th>Id</th>
        <th>Descrição</th>
        <th>Custo</th>  
        <th>Passo</th>
        <th>Requisitos</th>  
        <th>Benefícios</th>  
        <th>Ação</th>
    </tr>
<?if(count($this->tarefas) > 0):?>
    <?foreach($this->tarefas as $tarefa):?>
    <tr>
        <td><?=$tarefa->getId()?></td>
        <td><?=$tarefa->getNome()?></td>
        <td><?=$tarefa->getCusto()?></td>
        <td><?=$tarefa->getPasso()?>%</td>
        <td>
            <?if(!$tarefa->getRequisitos()->isEmpty()):?>
            <ul>
            <?foreach($tarefa->getRequisitos() as $requisito):?>
                <li>Requisito: <?=$this->partial('_partials/'.end(explode('\\', get_class($requisito))).'.phtml', array('requisito'=>$requisito));?></li>
            <?endforeach;?>
            </ul>
            <?endif;?>
        </td>
        <td>
            <?if(!$tarefa->getBeneficios()->isEmpty()):?>
            <ul>
            <?foreach($tarefa->getBeneficios() as $beneficio):?>
                <li><?=$this->partial('_partials/'.end(explode('\\', get_class($beneficio))).'.phtml', array('beneficio'=>$beneficio));?></li>
            <?endforeach;?>
            </ul>
            <?endif;?>
        </td>
        <td>
            <a href="<?=$this->url(array('controller'=>'tarefas','action'=>'show','id'=> $tarefa->getId()));?>">Ver</a> | 
            <a href="<?=$this->url(array('controller'=>'tarefas','action'=>'edit','id'=> $tarefa->getId()));?>">Editar</a> | 
            <a class="confirm" href="<?=$this->url(array('controller'=>'tarefas','action'=>'delete','id'=> $tarefa->getId()));?>">Excluir</a>
        </td>
    </tr>
    <?endforeach;?>
<?endif;?>
</table>